package item.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import item.model.ItemInfo;

import com.util.SqlMapLocator;

public class ItemDAO {
	private static ItemDAO singleton;
	private ItemDAO(){
	}
	public static ItemDAO getInstance(){
		if(singleton == null)
			singleton = new ItemDAO();
		return singleton;
	}
	
	public List<ItemInfo> select(Object obj) throws Exception{
		return (List<ItemInfo>)SqlMapLocator.getMapper().queryForList("itemSelect",obj);
	}
	public ItemInfo selectOne(int obj) throws Exception{
		return (ItemInfo)SqlMapLocator.getMapper().queryForObject("ItemSelectOne",obj);
	}
	public int selectCnt(String cate) throws Exception{
		return (Integer)SqlMapLocator.getMapper().queryForObject("ItemCnt",cate);
	}
	public void insert(Object obj) throws Exception{
		SqlMapLocator.getMapper().insert("ItemInsert",(ItemInfo)obj);
	}
	public void update(ItemInfo itemInfo) throws Exception{
		SqlMapLocator.getMapper().update("ItemUpdate",(ItemInfo)itemInfo);
	}
	public void delete(int ItemNo) throws Exception{
		SqlMapLocator.getMapper().update("ItemDelete",ItemNo);
	}
	public List<ItemInfo> selectTopItem() throws Exception{
		return (List<ItemInfo>)SqlMapLocator.getMapper().queryForList("ItemTopSelect");
	}
}
